#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "cJSON.h"

void print(cJSON* argv, cJSON* retval)
{
	printf("Now in @print.\n");
}

void numerial_calculate(cJSON* argv, cJSON* retval)
{
	printf("Now in @numerial_calculate\n");
	/* json对象转换为传入参数 */
	int a = cJSON_GetObjectItem(argv, "a")->valueint;
	int b = cJSON_GetObjectItem(argv, "b")->valueint;

	/* 事务处理 */
	int c = a + b;
	int d = a * b;
	double f = 3.14 * b;

	/* 返回值集合添加成员 */
	cJSON_AddNumberToObject(retval, "sum", 		c);
	cJSON_AddNumberToObject(retval, "multi", 	d);
	cJSON_AddNumberToObject(retval, "realnum", 	f);
	cJSON_AddStringToObject(retval, "status", 	"normal");
}